<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
</html>

<script>
  const canvas = document.createElement("canvas");
  canvas.width = 600;
  canvas.height = 400;
  document.body.append(canvas);
  const context = canvas.getContext("2d");

  //   画线
  context.moveTo(100, 100);
  context.lineTo(300, 100);
  //   设置线条的宽度,
  context.lineWidth = 10;

  //   使用strokeStyle修改颜色
  context.strokeStyle = "#0c0";

  context.stroke();

  //   当你想继续画的时候，它的开始点就在 你上一个的结束坐标了因为你没有close，所以它是不会抬笔的
  context.lineTo(200, 200);
  context.stroke();
</script>
